package dhm.com.hpx.activity;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import dhm.com.hpx.R;
import dhm.com.hpx.base.BaseActivity;


public class MsgActivity extends BaseActivity {

    @BindView(R.id.red)
    LinearLayout red;
    @BindView(R.id.text_phone)
    TextView textPhone;
    @BindView(R.id.edit_msg)
    EditText editMsg;
    private String phone;

    @Override
    protected int getLayout() {
        return R.layout.activity_msg;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        phone = getIntent().getStringExtra("phone");
        textPhone.setText(phone);

    }

    @Override
    protected void initData() {
    }

    @OnClick({R.id.back, R.id.redx, R.id.add, R.id.send, R.id.choose})
    public void onViewClicked(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.redx:
                red.setVisibility(View.GONE);
                break;
            case R.id.add:
                finish();
                break;
            case R.id.choose:
                intent=new Intent(MsgActivity.this, SpeechcraftActivity.class);
                startActivity(intent);
                break;
            case R.id.send:

                String s = editMsg.getText().toString();
                if (s==null||s.equals("")){
                    Toast.makeText(this, "请编辑群发内容", Toast.LENGTH_SHORT).show();
                    return;
                }

                Uri smsToUri = Uri.parse("smsto:"+phone);

                intent = new Intent(Intent.ACTION_SENDTO, smsToUri);

                intent.putExtra("sms_body", s);
                startActivity(intent);
                finish();
                break;
                default:
        }
    }
}
